//-------------------------------------------------------------------------------------------------
//  plane.hpp - Definition of plane class (of infinite size) for physics operations
//  (c) 2009 Simon Miessler
//-------------------------------------------------------------------------------------------------

#pragma once

#include <boost/optional.hpp>

#include "math_exports.hpp"
#include "geometry_fwd.hpp"
#include "ray.hpp"
#include "raycastable.hpp"




namespace math
{
	/**
	 * Plane in 3d space with infinite size.
	 */
	template <typename T>
	class plane
		: public intersectable< plane<T> >
		, public raycastable< plane<T>, T >
	{
	public:

		/// The used floating-point type
		typedef T              float_t;

	public:

		/// The position of the plane
		vector3<T>   position;

		/// The normal of the plane
		vector3<T>   normal;

	public:

		/**
		 * Create a plane.
		 * Positioned at (0,0,0) with (0,1,0) as a normal
		 */
		plane()
			: position(0, 0, 0)
			, normal(0, 1, 0)
		{}

		/**
		 * Create a plane at the specified position and
		 * the specified normal.
		 *
		 * @param position   the position of the plane in world space
		 * @param normal     the normal (facing direction) of the plane
		 */
		plane(const vector3<T>& position, const vector3<T>& normal)
			: position(position)
			, normal(normal)
		{}
	};
	///////////////////////////////////////////////////////////////////////////////////////////////




	/**
	 * In order to compile a binary that actually contains the code for our planes,
	 * we have to explicitly instantiate the template planes and export those:
	 */
	template struct MATH_API intersectable< plane<float> >;
	template struct MATH_API intersectable< plane<double> >;
	template struct MATH_API raycastable< plane<float>, float>;
	template struct MATH_API raycastable< plane<double>, double>;
	template class MATH_API plane<float>;
	template class MATH_API plane<double>;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
